<?php

/**
 * @author Christopher Hazekamp
 * @copyright 2013
 */

//$db = new PDO("mysql:host=localhost;dbname=portfolio_db;", 'root', '');
//$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
//$db->setFetchMode(PDO::FETCH_ASSOC);
require('pdo.php');
$db = new Database;

?>

<a href="pdo_insert.php">Rij toevoegen</a>

<table>
	<tr>
		<th>ID</th>
		<th>Name</th>
		<th>Location</th>
		<th>Gender</th>
	</tr>
	<tr>
		<td colspan="4">Hallo <?php echo $db->sqlCount('people'); ?></th>
	</tr>
<?php
$db->query("SELECT * FROM people ORDER BY name ASC");
foreach ($db->resultSet() as $row)
{
	switch ($row['gender'])
	{
		case 'f': $row['gender'] = 'Female';	break;
		case 'm': $row['gender'] = 'Male';	break;
		default : $row['gender'] = 'N/A';	break;
	}
	echo "<tr>";
	echo "<td>" . $row['id'] . "</td>";
	echo "<td><a href='item.php?id=".$row['id']."'>" . $row['name'] . "</a></td>";
	echo "<td>" . $row['location'] . "</td>";
	echo "<td>" . $row['gender'] . "</td>";
	echo "<td><a href='pdo_delete.php?id=".$row['id']."'>Delete</a></td>";
	echo "</tr>";
}

?>

</table>